package cn.jbooter.restweb.autoconfigure.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.jbooter.coms.pojos.Page;
import cn.jbooter.restweb.frame.api.CodeTableApi;
import cn.jbooter.restweb.frame.bo.CodeBo;

/**
 * 码表
 * @author hejian
 *
 */
@Controller
@RequestMapping(value="/frame")
public class CodeController {
	
	@Autowired
	private CodeTableApi codeTableApi;

	/**
	 * 根据码类获取其下的码值,返回格式由实现类决定
	 * @param page
	 * @param codes
	 * @return
	 */
	@ResponseBody
	@RequestMapping( value = "/code", method = RequestMethod.POST )
	public Page<?> code( Page<?> page, @RequestBody List<CodeBo> codes ) {
		if (codes.size() == 0 ) return page;
		Map<String, Object> map = codeTableApi.getCodesByType(codes);
		page.setMap(map);
		return page;
	}
	
}
